<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>
<head>
    <title>CSS Test: :empty after removing a non-empty child</title>
    <style type="text/css">
    div
    {
        color: red;
    }
    div:empty + div
    {
        color: green;
    }
</style>

</head>
<body>
    <p>The test passes if the Filler Text below is green.</p>
    <div id="parent"><span>Filler Text</span></div>
    <div id="test">Filler Text</div>
    <div id="testresult" style="color: blue">Running</div>
    <script type="text/javascript">
            function ArrayContains(array, value, ci)
            {
                ci = ci == true ? true : false;
                for (var i = 0; i < array.length; i++)
                {
                    if (ci && array[i].toLowerCase() == value.toLowerCase())
                    {
                        return true;
                    }
                    else if (array[i] == value)
                    {
                        return true;
                    }
                }
                return false;
            }
            function IsGreen(elem)
            {

                var val = getComputedStyle(elem, null).getPropertyValue("color");
                var aExpectedValues = new Array("green", "#008000", "rgb(0, 128, 0)");

                if (ArrayContains(aExpectedValues, val, true))
                {
                    return true;
                }
                else
                {
                    ResultComment = "Unexpected value: " + val;
                    return false;
                }
            }

            function doStuff()
            {
                try
                {
                 var parent = document.getElementById("parent");
                 parent.removeChild(parent.childNodes[0]);
                 var elem = document.getElementById("test");
                 if (IsGreen(elem))
                 {
                      document.getElementById("testresult").innerHTML = "Pass";
                      return;
                 }
                }
                catch(e){}

                document.getElementById("testresult").innerHTML = "Fail";
            }
            window.setTimeout("doStuff()", 300);
        
    </script>
</body>
</html>
